from pydantic import BaseModel
from typing import Optional, List
from datetime import datetime

# 用户注册请求体
class UserCreate(BaseModel):
    username: str
    password: str

# 用户登录请求体
class UserLogin(BaseModel):
    username: str
    password: str

# 用户响应模型
class UserResponse(BaseModel):
    id: int
    username: str
    created_at: datetime

    class Config:
        from_attributes = True

# 用户更新请求体
class UserUpdate(BaseModel):
    username: Optional[str] = None
    password: Optional[str] = None

# Token响应模型
class Token(BaseModel):
    access_token: str
    token_type: str

# Token载荷
class TokenPayload(BaseModel):
    sub: str  # 用户ID
    exp: int  # 过期时间
